import Axios from './../utils/axios';
import api from '@/api';
import qs from 'qs'

//获取商品列表信息
function getShopList(currentPage,pageSize){
    // console.log("service",currentPage,pageSize);
    return Axios.post(api.shop.GetShopList,{currentPage,pageSize});
}
//获取分类
function getQueryClass(){
    return Axios.get(api.shop.GetQueryClass);
}
//搜索
function searchShop(keyWords,categoryId,status,brand){
    return Axios.post(api.shop.GetShopList,{keyWords,categoryId,status,brand})
}
//查看商品详情
function checkShopDetail(id){
    return Axios.get(api.shop.GetShopList+`/${id}`)
}
//删除
function deleteShop(id){
    return Axios.post(api.shop.DelShopById+`/${id}`)
}
//编辑
function editShopInfo(prodId){
    return Axios.put(api.shop.GetShopList,{prodId})
}
//批量上架
function batchUpShop(ids){
    // console.log('14',ids);
    return Axios({
        method:"put",
        url:api.shop.BatchUpShop,
        params:ids
    })
}
//批量下架
function batchDownShop(ids){
    return Axios({
        method:"put",
        url:api.shop.BatchDownShop,
        params:ids
    })
}
//标签
function shopListTag(data){
    return Axios.post(api.shop.GetShopList,data);
}
/************************************************************************/

//商品审核信息
function getShopAuditList(currentPage,pageSize){
    return Axios.post(api.shop.AuditInquireList,{currentPage,pageSize});
}
//搜索
function searchShopAudit(keyWords,categoryId,brand,status){
    return Axios.post(api.shop.AuditInquireList,{keyWords,categoryId,brand,status})
}
//删除
function deleteAudit(id){
    return Axios.post(api.shop.DelAuditShop+`/${id}`)
}
//审核商品
function auditShop(data){
    console.log(data);
    return Axios({
        method:'put',
        url: api.shop.AuditShop,
        params:data
    })
}
//标签
function auditListTag(data){
    return Axios.post(api.shop.AuditInquireList,data);
}

/***********************************************************************/

//获取商品评论
function getAssessList(currentPage,pageSize){
    return Axios.post(api.shop.GetAssessList,{currentPage,pageSize});
}
//获取评论信息
function checkAssessDetail(id){
    return Axios.get(api.shop.GetAssessList+`/${id}`)
}
//搜索
function queryAssess(prodName,nickName){
    return Axios.post(api.shop.GetAssessList,{prodName,nickName})
}
//删除
function deleteAssess(idList){
    // console.log('6',idList);
    return Axios.delete(api.shop.GetAssessList,{params:{idList}})
}
//回复评论
function replyAssess(replyContent){
    return Axios.put(api.shop.GetAssessList,{replyContent})
}
//是否显示评论
function showAssess(prodCommId,status){
    console.log('19',prodCommId,status );
    return Axios.put(api.shop.ShowAssess,{prodCommId,status})
}

/***********************************************************************/

//商品库存
function getShopStockList(currentPage,pageSize){
    return Axios.post(api.shop.GetShopStockList,{currentPage,pageSize});
}
//删除
function delShopStock(id){
    return Axios.delete(api.shop.DelStockById,{data:{id}})
}
//批量删除
function batchDelShopStock(ids){
    return Axios.delete(api.shop.BatchDelStockById,{data:{ids}})
}
//是否启用
function singleUpDownOne(id,status){
    return Axios.put(api.shop.SingleUpDown,{id,status})
}

/***********************************************************************/

//商品回收站
function inquireRecycle(currentPage,pageSize){
    return Axios.post(api.shop.InquireRecycle,{currentPage,pageSize});
}
//搜索
function searchShopRecycle(prodName,categoryId){
    return Axios.post(api.shop.InquireRecycle,{prodName,categoryId});
}
//删除
function deleteRecycleShop(id){
    return Axios.delete(api.shop.DelRecycleShopById+`/${id}`);
}
//批量删除
function batchDeleteRecycleShop(idList){
    return Axios.post(api.shop.BatchDelRecycle,{idList});
}
//还原
function reductionRecycleShop(id){
    return Axios.put(api.shop.ReductionShop+`/${id}`);
}




function GetShopListClassify(data) { //获取商品分类列表
    return Axios.post(api.shop.GetShopListClassify, data)
}

function GetShopListSecond(data) {   //获取商品二级分类列表
    // console.log(data);
    return Axios.post(api.shop.GetShopListTwo, data)
}

function UpdateShopClass(data) {  //更新数据
    return Axios.post(api.shop.UpdateShopClass,
        data
    )
}

//获取分类
function GetAllClass() {
    return Axios.get(api.shop.GetAllClass);
}

function DelShopClassById(id) {
    return Axios.get(api.shop.DelShopClassById + `/${id}`)
}

// 根据id查询商品详情数据
function GetShopListById(id) {
    console.log("action", id);
    return Axios.post(api.shop.GetShopListById + `/${id}`)
}

// 修改分类详情数据
function EditShopClass(data) {
    console.log(data);
    return Axios.post(api.shop.EditShopClass, data)
}

// 单文件上传
function UploadFile(data) {
    return Axios.post(api.shop.UploadFile, data, {
        headers: {
            'Content-Type': 'multipart/form-data',
            // other headers here...
        }
    })
}
// 多文件上传
function UploadFiles(data) {
    return Axios.post(api.shop.UploadFiles, data,{
        headers: {
            'Content-Type': 'multipart/form-data',
            // other headers here...
        }
    })
}

// 添加分类
function AddShopClass(data) {
    console.log('service', data);
    return Axios.post(api.shop.AddShopClass, data)
}

// 新增商品
function AddShopInfo(data){
    return Axios.post(api.shop.AddShopInfo,data)
}

export default {
    getShopList,//获取商品列表数据
    getQueryClass,//获取分类数据
    searchShop,//搜索
    checkShopDetail,//查看商品详情
    deleteShop,//删除商品列表数据
    editShopInfo,//修改商品列表数据
    auditShop,//审核商品
    batchUpShop,//批量上架
    batchDownShop,//批量下架
    shopListTag,//标签

    getShopAuditList,//获取审核数据
    searchShopAudit,//搜索
    deleteAudit,//删除审核未通过商品
    auditListTag,//标签

    getAssessList,//获取评价数据
    checkAssessDetail,//查看评价详情
    queryAssess,//搜索
    deleteAssess,//删除
    batchDelShopStock,//批量删除
    replyAssess,//回复评论
    showAssess,//是否显示评论

    getShopStockList,//获取商品库存数据
    delShopStock,//删除
    singleUpDownOne,//单个是否启用

    inquireRecycle,//获取商品回收站数据
    searchShopRecycle,//搜索
    deleteRecycleShop,//删除
    batchDeleteRecycleShop,//批量删除
    reductionRecycleShop,//还原

    GetShopListClassify,
    GetShopListSecond,
    UpdateShopClass,
    GetShopListById,
    AddShopClass,
    EditShopClass,
    DelShopClassById,
    UploadFile,
    UploadFiles,
    GetAllClass,
    AddShopInfo,
}


